/*
 * @Description: 
 * @FilePath: \hk-computerRoom-Security\src\api\menu\index.ts
 * @Date: 2024-01-02 14:11:40
 * @LastEditTime: 2024-01-05 10:23:37
 */
import request from '/@/utils/request';

/**
 * 菜单管理-api文件
 *
 * 后端控制菜单模拟json，路径在 https://gitee.com/lyt-top/vue-next-admin-images/tree/master/menu
 * 后端控制路由，isRequestRoutes 为 true，则开启后端控制路由
 * @method getAllMenu 查询总菜单权限树
 * @method addMenu 添加菜单
 * @method updateMenu 修改菜单
 * @method switchMenu 切换菜单状态(禁用\启用)
 * @method deleteMenuById 删除菜单
 * @method getUserMenuTree 查询用户菜单权限树
 * @method getUserMenuTreeInAll 查询用户权限在总权限树中的选中状态
 */
export function useMenuApi() {
  return {
    getAllMenu: (params?: object) => {
      return request({
        url: '/api/menu/getAllMenuTree',
        method: 'POST',
        params,
        // headers: {
        //   'content-type': "application/x-www-form-urlencoded"
        // }
      });
    },
    addMenu: (params?: object) => {
      return request({
        url: '/api/menu/createMenu',
        method: 'POST',
        data: params,
      });
    },
    updateMenu: (params?: object) => {
      return request({
        url: '/api/menu/updateMenu',
        method: 'POST',
        data: params,
      });
    },
    switchMenu: (params?: object) => {
      return request({
        url: '/api/menu/switchMenu',
        method: 'POST',
        data: params,
      });
    },
    deleteMenuById: (id: string) => {
      return request({
        url: `/api/menu/deleteMenu/${id}`,
        method: 'get',
      });
    },
    getUserMenuTree: (params?: object) => {
      return request({
        url: '/api/menu/getUserMenuTree',
        method: 'POST',
        data: params,
      });
    },
    getUserMenuTreeInAll: (params?: object) => {
      return request({
        url: '/api/menu/getUserMenuTreeInAll',
        method: 'POST',
        data: params,
      });
    },
  };
}
